home *** CD-ROM | disk | FTP | other *** search
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- NNNNAAAAMMMMEEEE
- perltie - how to hide an object class in a simple variable
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- ttttiiiieeee VVVVAAAARRRRIIIIAAAABBBBLLLLEEEE,,,, CCCCLLLLAAAASSSSSSSSNNNNAAAAMMMMEEEE,,,, LLLLIIIISSSSTTTT
-
- $$$$oooobbbbjjjjeeeecccctttt ==== ttttiiiieeeedddd VVVVAAAARRRRIIIIAAAABBBBLLLLEEEE
-
- uuuunnnnttttiiiieeee VVVVAAAARRRRIIIIAAAABBBBLLLLEEEE
-
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- Prior to release 5.0 of Perl, a programmer could use
- _d_b_m_o_p_e_n_(_) to magically connect an on-disk database in the
- standard Unix _d_b_m(3x) format to a %%%%HHHHAAAASSSSHHHH in their program.
- However, their Perl was either built with one particular
- dbm library or another, but not both, and you couldn't
- extend this mechanism to other packages or types of
- variables.
-
- Now you can.
-
- The _t_i_e_(_) function binds a variable to a class (package)
- that will provide the implementation for access methods
- for that variable. Once this magic has been performed,
- accessing a tied variable automatically triggers method
- calls in the proper class. All of the complexity of the
- class is hidden behind magic methods calls. The method
- names are in ALL CAPS, which is a convention that Perl
- uses to indicate that they're called implicitly rather
- than explicitly--just like the _B_E_G_I_N_(_) and _E_N_D_(_)
- functions.
-
- In the _t_i_e_(_) call, VVVVAAAARRRRIIIIAAAABBBBLLLLEEEE is the name of the variable to
- be enchanted. CCCCLLLLAAAASSSSSSSSNNNNAAAAMMMMEEEE is the name of a class
- implementing objects of the correct type. Any additional
- arguments in the LLLLIIIISSSSTTTT are passed to the appropriate
- constructor method for that class--meaning _T_I_E_S_C_A_L_A_R_(_),
- _T_I_E_A_R_R_A_Y_(_), or _T_I_E_H_A_S_H_(_). (Typically these are arguments
- such as might be passed to the _d_b_m_i_n_i_t_(_) function of C.)
- The object returned by the "new" method is also returned
- by the _t_i_e_(_) function, which would be useful if you wanted
- to access other methods in CCCCLLLLAAAASSSSSSSSNNNNAAAAMMMMEEEE. (You don't actually
- have to return a reference to a right "type" (e.g. HASH or
- CCCCLLLLAAAASSSSSSSSNNNNAAAAMMMMEEEE) so long as it's a properly blessed object.)
- You can also retrieve a reference to the underlying object
- using the _t_i_e_d_(_) function.
-
- Unlike _d_b_m_o_p_e_n_(_), the _t_i_e_(_) function will not uuuusssseeee or
- rrrreeeeqqqquuuuiiiirrrreeee a module for you--you need to do that explicitly
- yourself.
-
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 1
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- TTTTyyyyiiiinnnngggg SSSSccccaaaallllaaaarrrrssss
-
- A class implementing a tied scalar should define the
- following methods: TIESCALAR, FETCH, STORE, and possibly
- DESTROY.
-
- Let's look at each in turn, using as an example a tie
- class for scalars that allows the user to do something
- like:
-
- ttttiiiieeee $$$$hhhhiiiissss____ssssppppeeeeeeeedddd,,,, ''''NNNNiiiicccceeee'''',,,, ggggeeeettttppppppppiiiidddd(((())));;;;
- ttttiiiieeee $$$$mmmmyyyy____ssssppppeeeeeeeedddd,,,, ''''NNNNiiiicccceeee'''',,,, $$$$$$$$;;;;
-
- And now whenever either of those variables is accessed,
- its current system priority is retrieved and returned. If
- those variables are set, then the process's priority is
- changed!
-
- We'll use Jarkko Hietaniemi _<_J_a_r_k_k_o_._H_i_e_t_a_n_i_e_m_i_@_h_u_t_._f_i_>'s
- BSD::Resource class (not included) to access the
- PRIO_PROCESS, PRIO_MIN, and PRIO_MAX constants from your
- system, as well as the _g_e_t_p_r_i_o_r_i_t_y_(_) and _s_e_t_p_r_i_o_r_i_t_y_(_)
- system calls. Here's the preamble of the class.
-
- ppppaaaacccckkkkaaaaggggeeee NNNNiiiicccceeee;;;;
- uuuusssseeee CCCCaaaarrrrpppp;;;;
- uuuusssseeee BBBBSSSSDDDD::::::::RRRReeeessssoooouuuurrrrcccceeee;;;;
- uuuusssseeee ssssttttrrrriiiicccctttt;;;;
- $$$$NNNNiiiicccceeee::::::::DDDDEEEEBBBBUUUUGGGG ==== 0000 uuuunnnnlllleeeessssssss ddddeeeeffffiiiinnnneeeedddd $$$$NNNNiiiicccceeee::::::::DDDDEEEEBBBBUUUUGGGG;;;;
-
-
- TIESCALAR classname, LIST
- This is the constructor for the class. That means it
- is expected to return a blessed reference to a new
- scalar (probably anonymous) that it's creating. For
- example:
-
- ssssuuuubbbb TTTTIIIIEEEESSSSCCCCAAAALLLLAAAARRRR {{{{
- mmmmyyyy $$$$ccccllllaaaassssssss ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ppppiiiidddd ==== sssshhhhiiiifffftttt |||||||| $$$$$$$$;;;; #### 0000 mmmmeeeeaaaannnnssss mmmmeeee
-
- iiiiffff (((($$$$ppppiiiidddd !!!!~~~~ ////^^^^\\\\dddd++++$$$$////)))) {{{{
- ccccaaaarrrrpppp """"NNNNiiiicccceeee::::::::TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr ggggooootttt nnnnoooonnnn----nnnnuuuummmmeeeerrrriiiicccc ppppiiiidddd $$$$ppppiiiidddd"""" iiiiffff $$$$^^^^WWWW;;;;
- rrrreeeettttuuuurrrrnnnn uuuunnnnddddeeeeffff;;;;
- }}}}
-
- uuuunnnnlllleeeessssssss ((((kkkkiiiillllllll 0000,,,, $$$$ppppiiiidddd)))) {{{{ #### EEEEPPPPEEEERRRRMMMM oooorrrr EEEERRRRSSSSCCCCHHHH,,,, nnnnoooo ddddoooouuuubbbbtttt
- ccccaaaarrrrpppp """"NNNNiiiicccceeee::::::::TTTTiiiieeee::::::::SSSSccccaaaallllaaaarrrr ggggooootttt bbbbaaaadddd ppppiiiidddd $$$$ppppiiiidddd:::: $$$$!!!!"""" iiiiffff $$$$^^^^WWWW;;;;
- rrrreeeettttuuuurrrrnnnn uuuunnnnddddeeeeffff;;;;
- }}}}
-
- rrrreeeettttuuuurrrrnnnn bbbblllleeeessssssss \\\\$$$$ppppiiiidddd,,,, $$$$ccccllllaaaassssssss;;;;
- }}}}
-
-
-
-
- 12/Feb/96 perl 5.002 with 2
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- This tie class has chosen to return an error rather
- than raising an exception if its constructor should
- fail. While this is how _d_b_m_o_p_e_n_(_) works, other
- classes may well not wish to be so forgiving. It
- checks the global variable $$$$^^^^WWWW to see whether to emit
- a bit of noise anyway.
-
- FETCH this
- This method will be triggered every time the tied
- variable is accessed (read). It takes no arguments
- beyond its self reference, which is the object
- representing the scalar we're dealing with. Since in
- this case we're just using a SCALAR ref for the tied
- scalar object, a simple $$self allows the method to
- get at the real value stored there. In our example
- below, that real value is the process ID to which
- we've tied our variable.
-
- ssssuuuubbbb FFFFEEEETTTTCCCCHHHH {{{{
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- ccccoooonnnnffffeeeessssssss """"wwwwrrrroooonnnngggg ttttyyyyppppeeee"""" uuuunnnnlllleeeessssssss rrrreeeeffff $$$$sssseeeellllffff;;;;
- ccccrrrrooooaaaakkkk """"uuuussssaaaaggggeeee eeeerrrrrrrroooorrrr"""" iiiiffff @@@@____;;;;
- mmmmyyyy $$$$nnnniiiicccceeeettttyyyy;;;;
- llllooooccccaaaallll(((($$$$!!!!)))) ==== 0000;;;;
- $$$$nnnniiiicccceeeettttyyyy ==== ggggeeeettttpppprrrriiiioooorrrriiiittttyyyy((((PPPPRRRRIIIIOOOO____PPPPRRRROOOOCCCCEEEESSSSSSSS,,,, $$$$$$$$sssseeeellllffff))));;;;
- iiiiffff (((($$$$!!!!)))) {{{{ ccccrrrrooooaaaakkkk """"ggggeeeettttpppprrrriiiioooorrrriiiittttyyyy ffffaaaaiiiilllleeeedddd:::: $$$$!!!!"""" }}}}
- rrrreeeettttuuuurrrrnnnn $$$$nnnniiiicccceeeettttyyyy;;;;
- }}}}
-
- This time we've decided to blow up (raise an
- exception) if the renice fails--there's no place for
- us to return an error otherwise, and it's probably
- the right thing to do.
-
- STORE this, value
- This method will be triggered every time the tied
- variable is set (assigned). Beyond its self
- reference, it also expects one (and only one)
- argument--the new value the user is trying to assign.
-
- ssssuuuubbbb SSSSTTTTOOOORRRREEEE {{{{
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- ccccoooonnnnffffeeeessssssss """"wwwwrrrroooonnnngggg ttttyyyyppppeeee"""" uuuunnnnlllleeeessssssss rrrreeeeffff $$$$sssseeeellllffff;;;;
- mmmmyyyy $$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy ==== sssshhhhiiiifffftttt;;;;
- ccccrrrrooooaaaakkkk """"uuuussssaaaaggggeeee eeeerrrrrrrroooorrrr"""" iiiiffff @@@@____;;;;
-
- iiiiffff (((($$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy <<<< PPPPRRRRIIIIOOOO____MMMMIIIINNNN)))) {{{{
- ccccaaaarrrrpppp sssspppprrrriiiinnnnttttffff
- """"WWWWAAAARRRRNNNNIIIINNNNGGGG:::: pppprrrriiiioooorrrriiiittttyyyy %%%%dddd lllleeeessssssss tttthhhhaaaannnn mmmmiiiinnnniiiimmmmuuuummmm ssssyyyysssstttteeeemmmm pppprrrriiiioooorrrriiiittttyyyy %%%%dddd"""",,,,
- $$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy,,,, PPPPRRRRIIIIOOOO____MMMMIIIINNNN iiiiffff $$$$^^^^WWWW;;;;
- $$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy ==== PPPPRRRRIIIIOOOO____MMMMIIIINNNN;;;;
- }}}}
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 3
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- iiiiffff (((($$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy >>>> PPPPRRRRIIIIOOOO____MMMMAAAAXXXX)))) {{{{
- ccccaaaarrrrpppp sssspppprrrriiiinnnnttttffff
- """"WWWWAAAARRRRNNNNIIIINNNNGGGG:::: pppprrrriiiioooorrrriiiittttyyyy %%%%dddd ggggrrrreeeeaaaatttteeeerrrr tttthhhhaaaannnn mmmmaaaaxxxxiiiimmmmuuuummmm ssssyyyysssstttteeeemmmm pppprrrriiiioooorrrriiiittttyyyy %%%%dddd"""",,,,
- $$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy,,,, PPPPRRRRIIIIOOOO____MMMMAAAAXXXX iiiiffff $$$$^^^^WWWW;;;;
- $$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy ==== PPPPRRRRIIIIOOOO____MMMMAAAAXXXX;;;;
- }}}}
-
- uuuunnnnlllleeeessssssss ((((ddddeeeeffffiiiinnnneeeedddd sssseeeettttpppprrrriiiioooorrrriiiittttyyyy((((PPPPRRRRIIIIOOOO____PPPPRRRROOOOCCCCEEEESSSSSSSS,,,, $$$$$$$$sssseeeellllffff,,,, $$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy)))))))) {{{{
- ccccoooonnnnffffeeeessssssss """"sssseeeettttpppprrrriiiioooorrrriiiittttyyyy ffffaaaaiiiilllleeeedddd:::: $$$$!!!!"""";;;;
- }}}}
- rrrreeeettttuuuurrrrnnnn $$$$nnnneeeewwww____nnnniiiicccceeeettttyyyy;;;;
- }}}}
-
-
- DESTROY this
- This method will be triggered when the tied variable
- needs to be destructed. As with other object
- classes, such a method is seldom ncessary, since Perl
- deallocates its moribund object's memory for you
- automatically--this isn't C++, you know. We'll use a
- DESTROY method here for debugging purposes only.
-
- ssssuuuubbbb DDDDEEEESSSSTTTTRRRROOOOYYYY {{{{
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- ccccoooonnnnffffeeeessssssss """"wwwwrrrroooonnnngggg ttttyyyyppppeeee"""" uuuunnnnlllleeeessssssss rrrreeeeffff $$$$sssseeeellllffff;;;;
- ccccaaaarrrrpppp """"[[[[ NNNNiiiicccceeee::::::::DDDDEEEESSSSTTTTRRRROOOOYYYY ppppiiiidddd $$$$$$$$sssseeeellllffff ]]]]"""" iiiiffff $$$$NNNNiiiicccceeee::::::::DDDDEEEEBBBBUUUUGGGG;;;;
- }}}}
-
-
- That's about all there is to it. Actually, it's more than
- all there is to it, since we've done a few nice things
- here for the sake of completeness, robustness, and general
- aesthetics. Simpler TIESCALAR classes are certainly
- possible.
-
- TTTTyyyyiiiinnnngggg AAAArrrrrrrraaaayyyyssss
-
- A class implementing a tied ordinary array should define
- the following methods: TIEARRAY, FETCH, STORE, and perhaps
- DESTROY.
-
- WWWWAAAARRRRNNNNIIIINNNNGGGG: Tied arrays are _i_n_c_o_m_p_l_e_t_e. They are also
- distinctly lacking something for the $$$$####AAAARRRRRRRRAAAAYYYY access (which
- is hard, as it's an lvalue), as well as the other obvious
- array functions, like _p_u_s_h_(_), _p_o_p_(_), _s_h_i_f_t_(_), _u_n_s_h_i_f_t_(_),
- and _s_p_l_i_c_e_(_).
-
- For this discussion, we'll implement an array whose
- indices are fixed at its creation. If you try to access
- anything beyond those bounds, you'll take an exception.
- (Well, if you access an individual element; an aggregate
- assignment would be missed.) For example:
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 4
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- rrrreeeeqqqquuuuiiiirrrreeee BBBBoooouuuunnnnddddeeeedddd____AAAArrrrrrrraaaayyyy;;;;
- ttttiiiieeee @@@@aaaarrrryyyy,,,, BBBBoooouuuunnnnddddeeeedddd____AAAArrrrrrrraaaayyyy,,,, 2222;;;;
- $$$$|||| ==== 1111;;;;
- ffffoooorrrr $$$$iiii ((((0000 ........ 11110000)))) {{{{
- pppprrrriiiinnnntttt """"sssseeeettttttttiiiinnnngggg iiiinnnnddddeeeexxxx $$$$iiii:::: """";;;;
- $$$$aaaarrrryyyy[[[[$$$$iiii]]]] ==== 11110000 **** $$$$iiii;;;;
- $$$$aaaarrrryyyy[[[[$$$$iiii]]]] ==== 11110000 **** $$$$iiii;;;;
- pppprrrriiiinnnntttt """"vvvvaaaalllluuuueeee ooooffff eeeelllltttt $$$$iiii nnnnoooowwww $$$$aaaarrrryyyy[[[[$$$$iiii]]]]\\\\nnnn"""";;;;
- }}}}
-
- The preamble code for the class is as follows:
-
- ppppaaaacccckkkkaaaaggggeeee BBBBoooouuuunnnnddddeeeedddd____AAAArrrrrrrraaaayyyy;;;;
- uuuusssseeee CCCCaaaarrrrpppp;;;;
- uuuusssseeee ssssttttrrrriiiicccctttt;;;;
-
-
- TIEARRAY classname, LIST
- This is the constructor for the class. That means it
- is expected to return a blessed reference through
- which the new array (probably an anonymous ARRAY ref)
- will be accessed.
-
- In our example, just to show you that you don't
- _r_e_a_l_l_y have to return an ARRAY reference, we'll
- choose a HASH reference to represent our object. A
- HASH works out well as a generic record type: the
- {{{{BBBBOOOOUUUUNNNNDDDD}}}} field will store the maximum bound allowed,
- and the C<{ARRAY} field will hold the true ARRAY ref.
- If someone outside the class tries to dereference the
- object returned (doubtless thinking it an ARRAY ref),
- they'll blow up. This just goes to show you that you
- should respect an object's privacy.
-
- ssssuuuubbbb TTTTIIIIEEEEAAAARRRRRRRRAAAAYYYY {{{{
- mmmmyyyy $$$$ccccllllaaaassssssss ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$bbbboooouuuunnnndddd ==== sssshhhhiiiifffftttt;;;;
- ccccoooonnnnffffeeeessssssss """"uuuussssaaaaggggeeee:::: ttttiiiieeee((((\\\\@@@@aaaarrrryyyy,,,, ''''BBBBoooouuuunnnnddddeeeedddd____AAAArrrrrrrraaaayyyy'''',,,, mmmmaaaaxxxx____ssssuuuubbbbssssccccrrrriiiipppptttt))))""""
- iiiiffff @@@@____ |||||||| $$$$bbbboooouuuunnnndddd ====~~~~ ////\\\\DDDD////;;;;
- rrrreeeettttuuuurrrrnnnn bbbblllleeeessssssss {{{{
- BBBBOOOOUUUUNNNNDDDD ====>>>> $$$$bbbboooouuuunnnndddd,,,,
- AAAARRRRRRRRAAAAYYYY ====>>>> [[[[]]]],,,,
- }}}},,,, $$$$ccccllllaaaassssssss;;;;
- }}}}
-
-
- FETCH this, index
- This method will be triggered every time an
- individual element the tied array is accessed (read).
- It takes one argument beyond its self reference: the
- index whose value we're trying to fetch.
-
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 5
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- ssssuuuubbbb FFFFEEEETTTTCCCCHHHH {{{{
- mmmmyyyy(((($$$$sssseeeellllffff,,,,$$$$iiiiddddxxxx)))) ==== @@@@____;;;;
- iiiiffff (((($$$$iiiiddddxxxx >>>> $$$$sssseeeellllffff---->>>>{{{{BBBBOOOOUUUUNNNNDDDD}}}})))) {{{{
- ccccoooonnnnffffeeeessssssss """"AAAArrrrrrrraaaayyyy OOOOOOOOBBBB:::: $$$$iiiiddddxxxx >>>> $$$$sssseeeellllffff---->>>>{{{{BBBBOOOOUUUUNNNNDDDD}}}}"""";;;;
- }}}}
- rrrreeeettttuuuurrrrnnnn $$$$sssseeeellllffff---->>>>{{{{AAAARRRRRRRRAAAAYYYY}}}}[[[[$$$$iiiiddddxxxx]]]];;;;
- }}}}
-
- As you may have noticed, the name of the FETCH method
- (et al.) is the same for all accesses, even though
- the constructors differ in names (TIESCALAR vs
- TIEARRAY). While in theory you could have the same
- class servicing several tied types, in practice this
- becomes cumbersome, and it's easiest to simply keep
- them at one tie type per class.
-
- STORE this, index, value
- This method will be triggered every time an element
- in the tied array is set (written). It takes two
- arguments beyond its self reference: the index at
- which we're trying to store something and the value
- we're trying to put there. For example:
-
- ssssuuuubbbb SSSSTTTTOOOORRRREEEE {{{{
- mmmmyyyy(((($$$$sssseeeellllffff,,,, $$$$iiiiddddxxxx,,,, $$$$vvvvaaaalllluuuueeee)))) ==== @@@@____;;;;
- pppprrrriiiinnnntttt """"[[[[SSSSTTTTOOOORRRREEEE $$$$vvvvaaaalllluuuueeee aaaatttt $$$$iiiiddddxxxx]]]]\\\\nnnn"""" iiiiffff ____ddddeeeebbbbuuuugggg;;;;
- iiiiffff (((($$$$iiiiddddxxxx >>>> $$$$sssseeeellllffff---->>>>{{{{BBBBOOOOUUUUNNNNDDDD}}}} )))) {{{{
- ccccoooonnnnffffeeeessssssss """"AAAArrrrrrrraaaayyyy OOOOOOOOBBBB:::: $$$$iiiiddddxxxx >>>> $$$$sssseeeellllffff---->>>>{{{{BBBBOOOOUUUUNNNNDDDD}}}}"""";;;;
- }}}}
- rrrreeeettttuuuurrrrnnnn $$$$sssseeeellllffff---->>>>{{{{AAAARRRRRRRRAAAAYYYY}}}}[[[[$$$$iiiiddddxxxx]]]] ==== $$$$vvvvaaaalllluuuueeee;;;;
- }}}}
-
-
- DESTROY this
- This method will be triggered when the tied variable
- needs to be destructed. As with the sclar tie class,
- this is almost never needed in a language that does
- its own garbage collection, so this time we'll just
- leave it out.
-
- The code we presented at the top of the tied array class
- accesses many elements of the array, far more than we've
- set the bounds to. Therefore, it will blow up once they
- try to access beyond the 2nd element of @@@@aaaarrrryyyy, as the
- following output demonstrates:
-
- sssseeeettttttttiiiinnnngggg iiiinnnnddddeeeexxxx 0000:::: vvvvaaaalllluuuueeee ooooffff eeeelllltttt 0000 nnnnoooowwww 0000
- sssseeeettttttttiiiinnnngggg iiiinnnnddddeeeexxxx 1111:::: vvvvaaaalllluuuueeee ooooffff eeeelllltttt 1111 nnnnoooowwww 11110000
- sssseeeettttttttiiiinnnngggg iiiinnnnddddeeeexxxx 2222:::: vvvvaaaalllluuuueeee ooooffff eeeelllltttt 2222 nnnnoooowwww 22220000
- sssseeeettttttttiiiinnnngggg iiiinnnnddddeeeexxxx 3333:::: AAAArrrrrrrraaaayyyy OOOOOOOOBBBB:::: 3333 >>>> 2222 aaaatttt BBBBoooouuuunnnnddddeeeedddd____AAAArrrrrrrraaaayyyy....ppppmmmm lllliiiinnnneeee 33339999
- BBBBoooouuuunnnnddddeeeedddd____AAAArrrrrrrraaaayyyy::::::::FFFFEEEETTTTCCCCHHHH ccccaaaalllllllleeeedddd aaaatttt tttteeeessssttttbbbbaaaa lllliiiinnnneeee 11112222
-
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 6
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- TTTTyyyyiiiinnnngggg HHHHaaaasssshhhheeeessss
-
- As the first Perl data type to be tied (see _d_b_m_o_p_e_n_(_)),
- associative arrays have the most complete and useful _t_i_e_(_)
- implementation. A class implementing a tied associative
- array should define the following methods: TIEHASH is the
- constructor. FETCH and STORE access the key and value
- pairs. EXISTS reports whether a key is present in the
- hash, and DELETE deletes one. CLEAR empties the hash by
- deleting all the key and value pairs. FIRSTKEY and
- NEXTKEY implement the _k_e_y_s_(_) and _e_a_c_h_(_) functions to
- iterate over all the keys. And DESTROY is called when the
- tied variable is garbage collected.
-
- If this seems like a lot, then feel free to merely inherit
- from the standard Tie::Hash module for most of your
- methods, redefining only the interesting ones. See the
- _T_i_e_:_:_H_a_s_h manpage for details.
-
- Remember that Perl distinguishes between a key not
- existing in the hash, and the key existing in the hash but
- having a corresponding value of uuuunnnnddddeeeeffff. The two
- possibilities can be tested with the eeeexxxxiiiissssttttssss(((()))) and
- ddddeeeeffffiiiinnnneeeedddd(((()))) functions.
-
- Here's an example of a somewhat interesting tied hash
- class: it gives you a hash representing a particular
- user's dotfiles. You index into the hash with the name of
- the file (minus the dot) and you get back that dotfile's
- contents. For example:
-
- uuuusssseeee DDDDoooottttFFFFiiiilllleeeessss;;;;
- ttttiiiieeee %%%%ddddooootttt,,,, DDDDoooottttFFFFiiiilllleeeessss;;;;
- iiiiffff (((( $$$$ddddooootttt{{{{pppprrrrooooffffiiiilllleeee}}}} ====~~~~ ////MMMMAAAANNNNPPPPAAAATTTTHHHH//// ||||||||
- $$$$ddddooootttt{{{{llllooooggggiiiinnnn}}}} ====~~~~ ////MMMMAAAANNNNPPPPAAAATTTTHHHH//// ||||||||
- $$$$ddddooootttt{{{{ccccsssshhhhrrrrcccc}}}} ====~~~~ ////MMMMAAAANNNNPPPPAAAATTTTHHHH//// ))))
- {{{{
- pppprrrriiiinnnntttt """"yyyyoooouuuu sssseeeeeeeemmmm ttttoooo sssseeeetttt yyyyoooouuuurrrr mmmmaaaannnnppppaaaatttthhhh\\\\nnnn"""";;;;
- }}}}
-
- Or here's another sample of using our tied class:
-
- ttttiiiieeee %%%%hhhhiiiimmmm,,,, DDDDoooottttFFFFiiiilllleeeessss,,,, ''''ddddaaaaeeeemmmmoooonnnn'''';;;;
- ffffoooorrrreeeeaaaacccchhhh $$$$ffff (((( kkkkeeeeyyyyssss %%%%hhhhiiiimmmm )))) {{{{
- pppprrrriiiinnnnttttffff """"ddddaaaaeeeemmmmoooonnnn ddddooootttt ffffiiiilllleeee %%%%ssss iiiissss ssssiiiizzzzeeee %%%%dddd\\\\nnnn"""",,,,
- $$$$ffff,,,, lllleeeennnnggggtttthhhh $$$$hhhhiiiimmmm{{{{$$$$ffff}}}};;;;
- }}}}
-
- In our tied hash DotFiles example, we use a regular hash
- for the object containing several important fields, of
- which only the {{{{LLLLIIIISSSSTTTT}}}} field will be what the user thinks
- of as the real hash.
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 7
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- USER whose dot files this object represents
-
- HOME where those dotfiles live
-
- CLOBBER
- whether we should try to change or remove those dot
- files
-
- LIST the hash of dotfile names and content mappings
-
- Here's the start of _D_o_t_f_i_l_e_s_._p_m:
-
- ppppaaaacccckkkkaaaaggggeeee DDDDoooottttFFFFiiiilllleeeessss;;;;
- uuuusssseeee CCCCaaaarrrrpppp;;;;
- ssssuuuubbbb wwwwhhhhoooowwwwaaaassssiiii {{{{ ((((ccccaaaalllllllleeeerrrr((((1111))))))))[[[[3333]]]] .... ''''(((())))'''' }}}}
- mmmmyyyy $$$$DDDDEEEEBBBBUUUUGGGG ==== 0000;;;;
- ssssuuuubbbb ddddeeeebbbbuuuugggg {{{{ $$$$DDDDEEEEBBBBUUUUGGGG ==== @@@@____ ???? sssshhhhiiiifffftttt :::: 1111 }}}}
-
- For our example, we want to able to emit debugging info to
- help in tracing during development. We keep also one
- convenience function around internally to help print out
- warnings; _w_h_o_w_a_s_i_(_) returns the function name that calls
- it.
-
- Here are the methods for the DotFiles tied hash.
-
- TIEHASH classname, LIST
- This is the constructor for the class. That means it
- is expected to return a blessed reference through
- which the new object (probably but not necessarily an
- anonymous hash) will be accessed.
-
- Here's the constructor:
-
- ssssuuuubbbb TTTTIIIIEEEEHHHHAAAASSSSHHHH {{{{
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$uuuusssseeeerrrr ==== sssshhhhiiiifffftttt |||||||| $$$$>>>>;;;;
- mmmmyyyy $$$$ddddoooottttddddiiiirrrr ==== sssshhhhiiiifffftttt |||||||| '''''''';;;;
- ccccrrrrooooaaaakkkk """"uuuussssaaaaggggeeee:::: @@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}} [[[[UUUUSSSSEEEERRRR [[[[DDDDOOOOTTTTDDDDIIIIRRRR]]]]]]]]"""" iiiiffff @@@@____;;;;
- $$$$uuuusssseeeerrrr ==== ggggeeeettttppppwwwwuuuuiiiidddd(((($$$$uuuusssseeeerrrr)))) iiiiffff $$$$uuuusssseeeerrrr ====~~~~ ////^^^^\\\\dddd++++$$$$////;;;;
- mmmmyyyy $$$$ddddiiiirrrr ==== ((((ggggeeeettttppppwwwwnnnnaaaammmm(((($$$$uuuusssseeeerrrr))))))))[[[[7777]]]]
- |||||||| ccccrrrrooooaaaakkkk """"@@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}}:::: nnnnoooo uuuusssseeeerrrr $$$$uuuusssseeeerrrr"""";;;;
- $$$$ddddiiiirrrr ....==== """"////$$$$ddddoooottttddddiiiirrrr"""" iiiiffff $$$$ddddoooottttddddiiiirrrr;;;;
-
- mmmmyyyy $$$$nnnnooooddddeeee ==== {{{{
- UUUUSSSSEEEERRRR ====>>>> $$$$uuuusssseeeerrrr,,,,
- HHHHOOOOMMMMEEEE ====>>>> $$$$ddddiiiirrrr,,,,
- LLLLIIIISSSSTTTT ====>>>> {{{{}}}},,,,
- CCCCLLLLOOOOBBBBBBBBEEEERRRR ====>>>> 0000,,,,
- }}}};;;;
-
-
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 8
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- ooooppppeeeennnnddddiiiirrrr((((DDDDIIIIRRRR,,,, $$$$ddddiiiirrrr))))
- |||||||| ccccrrrrooooaaaakkkk """"@@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}}:::: ccccaaaannnn''''tttt ooooppppeeeennnnddddiiiirrrr $$$$ddddiiiirrrr:::: $$$$!!!!"""";;;;
- ffffoooorrrreeeeaaaacccchhhh $$$$ddddooootttt (((( ggggrrrreeeepppp ////^^^^\\\\....//// &&&&&&&& ----ffff """"$$$$ddddiiiirrrr////$$$$____"""",,,, rrrreeeeaaaaddddddddiiiirrrr((((DDDDIIIIRRRR)))))))) {{{{
- $$$$ddddooootttt ====~~~~ ssss////^^^^\\\\....////////;;;;
- $$$$nnnnooooddddeeee---->>>>{{{{LLLLIIIISSSSTTTT}}}}{{{{$$$$ddddooootttt}}}} ==== uuuunnnnddddeeeeffff;;;;
- }}}}
- cccclllloooosssseeeeddddiiiirrrr DDDDIIIIRRRR;;;;
- rrrreeeettttuuuurrrrnnnn bbbblllleeeessssssss $$$$nnnnooooddddeeee,,,, $$$$sssseeeellllffff;;;;
- }}}}
-
- It's probably worth mentioning that if you're going
- to filetest the return values out of a readdir, you'd
- better prepend the directory in question. Otherwise,
- since we didn't _c_h_d_i_r_(_) there, it would have been
- testing the wrong file.
-
- FETCH this, key
- This method will be triggered every time an element
- in the tied hash is accessed (read). It takes one
- argument beyond its self reference: the key whose
- value we're trying to fetch.
-
- Here's the fetch for our DotFiles example.
-
- ssssuuuubbbb FFFFEEEETTTTCCCCHHHH {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ddddooootttt ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ddddiiiirrrr ==== $$$$sssseeeellllffff---->>>>{{{{HHHHOOOOMMMMEEEE}}}};;;;
- mmmmyyyy $$$$ffffiiiilllleeee ==== """"$$$$ddddiiiirrrr////....$$$$ddddooootttt"""";;;;
-
- uuuunnnnlllleeeessssssss ((((eeeexxxxiiiissssttttssss $$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}---->>>>{{{{$$$$ddddooootttt}}}} |||||||| ----ffff $$$$ffffiiiilllleeee)))) {{{{
- ccccaaaarrrrpppp """"@@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}}:::: nnnnoooo $$$$ddddooootttt ffffiiiilllleeee"""" iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- rrrreeeettttuuuurrrrnnnn uuuunnnnddddeeeeffff;;;;
- }}}}
-
- iiiiffff ((((ddddeeeeffffiiiinnnneeeedddd $$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}---->>>>{{{{$$$$ddddooootttt}}}})))) {{{{
- rrrreeeettttuuuurrrrnnnn $$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}---->>>>{{{{$$$$ddddooootttt}}}};;;;
- }}}} eeeellllsssseeee {{{{
- rrrreeeettttuuuurrrrnnnn $$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}---->>>>{{{{$$$$ddddooootttt}}}} ==== ````ccccaaaatttt $$$$ddddiiiirrrr////....$$$$ddddooootttt````;;;;
- }}}}
- }}}}
-
- It was easy to write by having it call the Unix
- _c_a_t(1) command, but it would probably be more
- portable to open the file manually (and somewhat more
- efficient). Of course, since dot files are a Unixy
- concept, we're not that concerned.
-
- STORE this, key, value
- This method will be triggered every time an element
- in the tied hash is set (written). It takes two
- arguments beyond its self reference: the index at
- which we're trying to store something, and the value
-
-
-
- 12/Feb/96 perl 5.002 with 9
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- we're trying to put there.
-
- Here in our DotFiles example, we'll be careful not to
- let them try to overwrite the file unless they've
- called the _c_l_o_b_b_e_r_(_) method on the original object
- reference returned by _t_i_e_(_).
-
- ssssuuuubbbb SSSSTTTTOOOORRRREEEE {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ddddooootttt ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$vvvvaaaalllluuuueeee ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ffffiiiilllleeee ==== $$$$sssseeeellllffff---->>>>{{{{HHHHOOOOMMMMEEEE}}}} .... """"////....$$$$ddddooootttt"""";;;;
- mmmmyyyy $$$$uuuusssseeeerrrr ==== $$$$sssseeeellllffff---->>>>{{{{UUUUSSSSEEEERRRR}}}};;;;
-
- ccccrrrrooooaaaakkkk """"@@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}}:::: $$$$ffffiiiilllleeee nnnnooootttt cccclllloooobbbbbbbbeeeerrrraaaabbbblllleeee""""
- uuuunnnnlllleeeessssssss $$$$sssseeeellllffff---->>>>{{{{CCCCLLLLOOOOBBBBBBBBEEEERRRR}}}};;;;
-
- ooooppppeeeennnn((((FFFF,,,, """">>>> $$$$ffffiiiilllleeee"""")))) |||||||| ccccrrrrooooaaaakkkk """"ccccaaaannnn''''tttt ooooppppeeeennnn $$$$ffffiiiilllleeee:::: $$$$!!!!"""";;;;
- pppprrrriiiinnnntttt FFFF $$$$vvvvaaaalllluuuueeee;;;;
- cccclllloooosssseeee((((FFFF))));;;;
- }}}}
-
- If they wanted to clobber something, they might say:
-
- $$$$oooobbbb ==== ttttiiiieeee %%%%ddddaaaaeeeemmmmoooonnnn____ddddoooottttssss,,,, ''''ddddaaaaeeeemmmmoooonnnn'''';;;;
- $$$$oooobbbb---->>>>cccclllloooobbbbbbbbeeeerrrr((((1111))));;;;
- $$$$ddddaaaaeeeemmmmoooonnnn____ddddoooottttssss{{{{ssssiiiiggggnnnnaaaattttuuuurrrreeee}}}} ==== """"AAAA ttttrrrruuuueeee ddddaaaaeeeemmmmoooonnnn\\\\nnnn"""";;;;
-
- Another way to lay hands on a reference to the
- underlying object is to use the _t_i_e_d_(_) function, so
- they might alternately have set clobber using:
-
- ttttiiiieeee %%%%ddddaaaaeeeemmmmoooonnnn____ddddoooottttssss,,,, ''''ddddaaaaeeeemmmmoooonnnn'''';;;;
- ttttiiiieeeedddd((((%%%%ddddaaaaeeeemmmmoooonnnn____ddddoooottttssss))))---->>>>cccclllloooobbbbbbbbeeeerrrr((((1111))));;;;
-
- The clobber method is simply:
-
- ssssuuuubbbb cccclllloooobbbbbbbbeeeerrrr {{{{
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- $$$$sssseeeellllffff---->>>>{{{{CCCCLLLLOOOOBBBBBBBBEEEERRRR}}}} ==== @@@@____ ???? sssshhhhiiiifffftttt :::: 1111;;;;
- }}}}
-
-
- DELETE this, key
- This method is triggered when we remove an element
- from the hash, typically by using the _d_e_l_e_t_e_(_)
- function. Again, we'll be careful to check whether
- they really want to clobber files.
-
- ssssuuuubbbb DDDDEEEELLLLEEEETTTTEEEE {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 10
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ddddooootttt ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ffffiiiilllleeee ==== $$$$sssseeeellllffff---->>>>{{{{HHHHOOOOMMMMEEEE}}}} .... """"////....$$$$ddddooootttt"""";;;;
- ccccrrrrooooaaaakkkk """"@@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}}:::: wwwwoooonnnn''''tttt rrrreeeemmmmoooovvvveeee ffffiiiilllleeee $$$$ffffiiiilllleeee""""
- uuuunnnnlllleeeessssssss $$$$sssseeeellllffff---->>>>{{{{CCCCLLLLOOOOBBBBBBBBEEEERRRR}}}};;;;
- ddddeeeelllleeeetttteeee $$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}---->>>>{{{{$$$$ddddooootttt}}}};;;;
- uuuunnnnlllliiiinnnnkkkk(((($$$$ffffiiiilllleeee)))) |||||||| ccccaaaarrrrpppp """"@@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}}:::: ccccaaaannnn''''tttt uuuunnnnlllliiiinnnnkkkk $$$$ffffiiiilllleeee:::: $$$$!!!!"""";;;;
- }}}}
-
-
- CLEAR this
- This method is triggered when the whole hash is to be
- cleared, usually by assigning the empty list to it.
-
- In our example, that would remove all the user's
- dotfiles! It's such a dangerous thing that they'll
- have to set CLOBBER to something higher than 1 to
- make it happen.
-
- ssssuuuubbbb CCCCLLLLEEEEAAAARRRR {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- ccccrrrrooooaaaakkkk """"@@@@{{{{[[[[&&&&wwwwhhhhoooowwwwaaaassssiiii]]]]}}}}:::: wwwwoooonnnn''''tttt rrrreeeemmmmoooovvvveeee aaaallllllll ddddoooottttffffiiiilllleeeessss ffffoooorrrr $$$$sssseeeellllffff---->>>>{{{{UUUUSSSSEEEERRRR}}}}""""
- uuuunnnnlllleeeessssssss $$$$sssseeeellllffff---->>>>{{{{CCCCLLLLOOOOBBBBBBBBEEEERRRR}}}} >>>> 1111;;;;
- mmmmyyyy $$$$ddddooootttt;;;;
- ffffoooorrrreeeeaaaacccchhhh $$$$ddddooootttt (((( kkkkeeeeyyyyssss %%%%{{{{$$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}}}}})))) {{{{
- $$$$sssseeeellllffff---->>>>DDDDEEEELLLLEEEETTTTEEEE(((($$$$ddddooootttt))));;;;
- }}}}
- }}}}
-
-
- EXISTS this, key
- This method is triggered when the user uses the
- _e_x_i_s_t_s_(_) function on a particular hash. In our
- example, we'll look at the {{{{LLLLIIIISSSSTTTT}}}} hash element for
- this:
-
- ssssuuuubbbb EEEEXXXXIIIISSSSTTTTSSSS {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$ddddooootttt ==== sssshhhhiiiifffftttt;;;;
- rrrreeeettttuuuurrrrnnnn eeeexxxxiiiissssttttssss $$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}---->>>>{{{{$$$$ddddooootttt}}}};;;;
- }}}}
-
-
- FIRSTKEY this
- This method will be triggered when the user is going
- to iterate through the hash, such as via a _k_e_y_s_(_) or
- _e_a_c_h_(_) call.
-
-
-
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 11
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- ssssuuuubbbb FFFFIIIIRRRRSSSSTTTTKKKKEEEEYYYY {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- mmmmyyyy $$$$aaaa ==== kkkkeeeeyyyyssss %%%%{{{{$$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}}}}};;;; #### rrrreeeesssseeeetttt eeeeaaaacccchhhh(((()))) iiiitttteeeerrrraaaattttoooorrrr
- eeeeaaaacccchhhh %%%%{{{{$$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}}}}}}
- }}}}
-
-
- NEXTKEY this, lastkey
- This method gets triggered during a _k_e_y_s_(_) or _e_a_c_h_(_)
- iteration. It has a second argument which is the
- last key that had been accessed. This is useful if
- you're carrying about ordering or calling the
- iterator from more than one sequence, or not really
- storing things in a hash anywhere.
-
- For our example, we our using a real hash so we'll
- just do the simple thing, but we'll have to indirect
- through the LIST field.
-
- ssssuuuubbbb NNNNEEEEXXXXTTTTKKKKEEEEYYYY {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- mmmmyyyy $$$$sssseeeellllffff ==== sssshhhhiiiifffftttt;;;;
- rrrreeeettttuuuurrrrnnnn eeeeaaaacccchhhh %%%%{{{{ $$$$sssseeeellllffff---->>>>{{{{LLLLIIIISSSSTTTT}}}} }}}}
- }}}}
-
-
- DESTROY this
- This method is triggered when a tied hash is about to
- go out of scope. You don't really need it unless
- you're trying to add debugging or have auxiliary
- state to clean up. Here's a very simple function:
-
- ssssuuuubbbb DDDDEEEESSSSTTTTRRRROOOOYYYY {{{{
- ccccaaaarrrrpppp &&&&wwwwhhhhoooowwwwaaaassssiiii iiiiffff $$$$DDDDEEEEBBBBUUUUGGGG;;;;
- }}}}
-
-
- Note that functions such as _k_e_y_s_(_) and _v_a_l_u_e_s_(_) may return
- huge array values when used on large objects, like DBM
- files. You may prefer to use the _e_a_c_h_(_) function to
- iterate over such. Example:
-
- #### pppprrrriiiinnnntttt oooouuuutttt hhhhiiiissssttttoooorrrryyyy ffffiiiilllleeee ooooffffffffsssseeeettttssss
- uuuusssseeee NNNNDDDDBBBBMMMM____FFFFiiiilllleeee;;;;
- ttttiiiieeee((((%%%%HHHHIIIISSSSTTTT,,,, NNNNDDDDBBBBMMMM____FFFFiiiilllleeee,,,, ''''////uuuussssrrrr////lllliiiibbbb////nnnneeeewwwwssss////hhhhiiiissssttttoooorrrryyyy'''',,,, 1111,,,, 0000))));;;;
- wwwwhhhhiiiilllleeee (((((((($$$$kkkkeeeeyyyy,,,,$$$$vvvvaaaallll)))) ==== eeeeaaaacccchhhh %%%%HHHHIIIISSSSTTTT)))) {{{{
- pppprrrriiiinnnntttt $$$$kkkkeeeeyyyy,,,, '''' ==== '''',,,, uuuunnnnppppaaaacccckkkk((((''''LLLL'''',,,,$$$$vvvvaaaallll)))),,,, """"\\\\nnnn"""";;;;
- }}}}
- uuuunnnnttttiiiieeee((((%%%%HHHHIIIISSSSTTTT))));;;;
-
-
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 12
-
-
-
-
-
- PERLTIE(1) User Contributed Perl Documentation PERLTIE(1)
-
-
- TTTTyyyyiiiinnnngggg FFFFiiiilllleeeeHHHHaaaannnnddddlllleeeessss
-
- This isn't implemented yet. Sorry; maybe someday.
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- See the _D_B___F_i_l_e manpage or the _C_o_n_f_i_g manpage for some
- interesting _t_i_e_(_) implementations.
-
- BBBBUUUUGGGGSSSS
- Tied arrays are _i_n_c_o_m_p_l_e_t_e. They are also distinctly
- lacking something for the $$$$####AAAARRRRRRRRAAAAYYYY access (which is hard,
- as it's an lvalue), as well as the other obvious array
- functions, like _p_u_s_h_(_), _p_o_p_(_), _s_h_i_f_t_(_), _u_n_s_h_i_f_t_(_), and
- _s_p_l_i_c_e_(_).
-
- You cannot easily tie a multilevel data structure (such as
- a hash of hashes) to a dbm file. The first problem is
- that all but GDBM and Berkeley DB have size limitations,
- but beyond that, you also have problems with how
- references are to be represented on disk. One
- experimental module that does attempt to partially address
- this need is the MLDBM module. Check your nearest CPAN
- site as described in the _p_e_r_l_m_o_d manpage for source code
- to MLDBM.
-
- AAAAUUUUTTTTHHHHOOOORRRR
- Tom Christiansen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 12/Feb/96 perl 5.002 with 13
-
-
-